perm filename CUT.SAI[NEW,AIL] blob sn#408261 filedate 1979-01-08 generic text, type T, neo UTF8
begin "cut"
   require "cs:std.hdr" source!file;
   integer inchan,outchan,current,eof,
           starting, ending,temp;
   write("Source file name: ");
   inchan := openin(inchwl,eof);
   write("Output file name:");
   outchan := openout(inchwl);
   write("Starting page number - ");
   read(starting);
   write ("Ending page number - ");
   read(ending);
   current := 1;
   while current neq starting do
   begin
      temp := wordin(inchan);
      if eof then
         begin
            write("No such starting page.");
            call(0,"exit");
         end;
      if temp = ff then
         current := current+1;
   end;

   while current neq ending+1 do
   begin
      temp := wordin(inchan);
      if eof then
         begin
            if current = ending then
               write("Successful completion of cut.")
            else
               write("End of file before page - ",ending);
            release(outchan);
            call(0,"exit");
         end;
      wordout(outchan,temp);
      if temp=ff then
          current := current+1;
   end;
   write("Successful completion of cut");
   release(OutChan);
   call(0,"exit");
end